#include "dialog.h"
#include "ui_dialog.h"
#include <QSettings>
#include <QDebug>

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog),
    m_setting("./config", QSettings::NativeFormat)
{
    ui->setupUi(this);

    connect(this, SIGNAL(test(uint)), this, SLOT(do_test(int)));
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_pushButton_clicked()
{
    Q_ASSERT(0000);
    m_setting.beginGroup("Config");
    m_setting.setValue("User", "Jake");
    m_setting.setValue("Passwd", "123456");
    m_setting.setValue("Size", 256);
    m_setting.endGroup();
}

void Dialog::on_pushButton_2_clicked()
{
    /*方式1*/
    qDebug()<<m_setting.value("Config/User").toString();
    qDebug()<<m_setting.value("Config/Passwd").value<QString>();
    /*方式2*/
    m_setting.beginGroup("Config");
    qDebug()<<m_setting.value("User").toString();
    qDebug()<<m_setting.value("Passwd").toString();
    qDebug()<<m_setting.value("Size").toInt();
    qDebug()<<m_setting.value("Test").toFloat();
    m_setting.endGroup();
}

void Dialog::do_test(int arg)
{
    arg = arg;
}
